package com.laitaoo.views.home.stock
{
	import com.laitaoo.event.StockListEvent;
	import com.laitaoo.views.BaseMediator;
	
	import mx.collections.ArrayCollection;
	
	[RouteEvents(events="updateStock")]
	[Component]
	public class StockListMediator extends BaseMediator
	{
		public function StockListMediator()
		{
			super();
		}
		[Bindable]
		public var dateList:ArrayCollection;
		
		public function updateStockItem(stockObj:Object):void{
			
			var stockEvent:StockListEvent = new StockListEvent(StockListEvent.UPDATESTOCK);
			stockEvent.stockObj = stockObj;
			eventBus.dispatchEvent(stockEvent);
		}
		/**
		 * 获取上货的日期列表
		 * */
		public function getStockDateList():void{
			
			var stockEvent:StockListEvent = new StockListEvent(StockListEvent.GETSTOCKDATELIST);
			eventBus.dispatchEvent(stockEvent);
		}
		[EventHandler]
		public function getStockDateListResultHandler(event:StockListEvent):void{
			
			dateList = event.dateList;
		}
		
		/**
		 * 获取当前日的进货信息
		 * */
		public function getStockList(dayId:int):void{
			
			var homeEvent:StockListEvent = new StockListEvent(StockListEvent.GETSTOCKLISTBYDAYID);
			homeEvent.dayId = dayId;
			eventBus.dispatchEvent(homeEvent);
		}
	}
}